/**
 * <copyright>
 * </copyright>
 *
 * $Id$
 */
package com.rd.xsd.common.impl;

import com.rd.xsd.common.CheckList;
import com.rd.xsd.common.CheckedItem;
import com.rd.xsd.common.CommonPackage;
import com.rd.xsd.common.Option;

import java.util.Collection;

import org.eclipse.emf.common.notify.NotificationChain;

import org.eclipse.emf.common.util.EList;

import org.eclipse.emf.ecore.EClass;
import org.eclipse.emf.ecore.InternalEObject;

import org.eclipse.emf.ecore.impl.EObjectImpl;

import org.eclipse.emf.ecore.util.EObjectContainmentEList;
import org.eclipse.emf.ecore.util.InternalEList;

/**
 * <!-- begin-user-doc -->
 * An implementation of the model object '<em><b>Check List</b></em>'.
 * <!-- end-user-doc -->
 * <p>
 * The following features are implemented:
 * <ul>
 *   <li>{@link com.rd.xsd.common.impl.CheckListImpl#getChecked <em>Checked</em>}</li>
 *   <li>{@link com.rd.xsd.common.impl.CheckListImpl#getOption <em>Option</em>}</li>
 * </ul>
 * </p>
 *
 * @generated
 */
public class CheckListImpl extends EObjectImpl implements CheckList {
	/**
	 * The cached value of the '{@link #getChecked() <em>Checked</em>}' containment reference list.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getChecked()
	 * @generated
	 * @ordered
	 */
	protected EList<CheckedItem> checked;

	/**
	 * The cached value of the '{@link #getOption() <em>Option</em>}' containment reference list.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getOption()
	 * @generated
	 * @ordered
	 */
	protected EList<Option> option;

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	protected CheckListImpl() {
		super();
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	protected EClass eStaticClass() {
		return CommonPackage.Literals.CHECK_LIST;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public EList<CheckedItem> getChecked() {
		if (checked == null) {
			checked = new EObjectContainmentEList<CheckedItem>(CheckedItem.class, this, CommonPackage.CHECK_LIST__CHECKED);
		}
		return checked;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public EList<Option> getOption() {
		if (option == null) {
			option = new EObjectContainmentEList<Option>(Option.class, this, CommonPackage.CHECK_LIST__OPTION);
		}
		return option;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public NotificationChain eInverseRemove(InternalEObject otherEnd, int featureID, NotificationChain msgs) {
		switch (featureID) {
			case CommonPackage.CHECK_LIST__CHECKED:
				return ((InternalEList<?>)getChecked()).basicRemove(otherEnd, msgs);
			case CommonPackage.CHECK_LIST__OPTION:
				return ((InternalEList<?>)getOption()).basicRemove(otherEnd, msgs);
		}
		return super.eInverseRemove(otherEnd, featureID, msgs);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public Object eGet(int featureID, boolean resolve, boolean coreType) {
		switch (featureID) {
			case CommonPackage.CHECK_LIST__CHECKED:
				return getChecked();
			case CommonPackage.CHECK_LIST__OPTION:
				return getOption();
		}
		return super.eGet(featureID, resolve, coreType);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@SuppressWarnings("unchecked")
	@Override
	public void eSet(int featureID, Object newValue) {
		switch (featureID) {
			case CommonPackage.CHECK_LIST__CHECKED:
				getChecked().clear();
				getChecked().addAll((Collection<? extends CheckedItem>)newValue);
				return;
			case CommonPackage.CHECK_LIST__OPTION:
				getOption().clear();
				getOption().addAll((Collection<? extends Option>)newValue);
				return;
		}
		super.eSet(featureID, newValue);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public void eUnset(int featureID) {
		switch (featureID) {
			case CommonPackage.CHECK_LIST__CHECKED:
				getChecked().clear();
				return;
			case CommonPackage.CHECK_LIST__OPTION:
				getOption().clear();
				return;
		}
		super.eUnset(featureID);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public boolean eIsSet(int featureID) {
		switch (featureID) {
			case CommonPackage.CHECK_LIST__CHECKED:
				return checked != null && !checked.isEmpty();
			case CommonPackage.CHECK_LIST__OPTION:
				return option != null && !option.isEmpty();
		}
		return super.eIsSet(featureID);
	}

} //CheckListImpl
